<?php
    session_start();
?>
<!-- InstanceBegin template="/Templates/admin_template.dwt.php" codeOutsideHTMLIsLocked="false" --><?php
	include("../Connect/connection.php")
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<title>Admin page</title>

<!-- CSS -->
<link href="style/css/transdmin.css" rel="stylesheet" type="text/css" media="screen" />
<!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie6.css" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie7.css" /><![endif]-->

<!-- JavaScripts-->
<script type="text/javascript" src="style/js/jquery.js"></script>
<script type="text/javascript" src="style/js/jNice.js"></script>
<script src="datetimepicker_css.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>

<body>
<div id="wrapper">
    	<!-- h1 tag stays for the logo, you can use the a tag for linking the index page -->
    	        
        <!-- You can name the links with lowercase, they will be transformed to uppercase by CSS, we prefered to name them with uppercase to have the same effect with disabled stylesheet -->
        <ul id="mainNav">
        	<li><a href="#" class="active">ADMIN</a></li> <!-- Use the "active" class for the active menu item  -->
        	
        	<li class="logout"><a href="login.php">LOGOUT</a></li>
        </ul>
        <!-- // #end mainNav -->
        <div id="containerHolder">
			<div id="container">
       		  <div id="sidebar">
                	<ul class="sideNav">
                    	<li><a href="listnews.php">List News</a></li>
                    	<li><a href="addnews.php">Add News</a></li>
                    	<li><a href="listcar.php">List Cars</a></li>
                    	<li><a href="addcar.php">Add Cars</a></li>
                    	<li><a href="listcompany.php">List Companies</a></li>
                    	<li><a href="addcompany.php">Add Companies</a></li>
                    	<li><a href="listorder.php">Oders</a></li>
                    	<li><a href="listordersubmit.php">Oders submit</a></li>
                    	<li><a href="listcustomer.php">Customers</a></li>
                    </ul>
                    <!-- // .sideNav -->
                </div>    
                <!-- // #sidebar -->
                
                <!-- h2 stays for breadcrumbs -->
                <!-- InstanceBeginEditable name="EditRegion2" -->
                <div id="main">
                <?php
                        if (!isset($_SESSION["AdminID"])){
                            echo("<script>alert('Login, please !');</script>");
                            echo("<script>window.location='login.php';</script>");
                        }else{
                            if($_SESSION["AdminID"] == ''){
                                echo("<script>alert('Dang Nhap, please !');</script>");
                                echo("<script>window.location='login.php';</script>");
                            }
              			}
                    ?>
                	<table style="border:1px solid #999">
                    <?php 
                $sql="Select * from ordercar where Status=0 order by CarID desc";
                $re=mysql_query($sql);
                while($rs=mysql_fetch_array($re)){
					$idOrder = $rs['OrderID'];
                    $carID=$rs['CarID'];
					$sqlCar="Select * from cars where CarID = $carID";
					$reCar=mysql_query($sqlCar);
               	    while($rsCar=mysql_fetch_array($reCar)){
						 $imageCar=$rsCar['Image'];
					}
                    $perID=$rs['PerID'];
					$sqlPer="Select * from persionorder where PerID = $perID";
					$rePer=mysql_query($sqlPer);
               	    while($rsPer=mysql_fetch_array($rePer)){
						 $perName=$rsPer['Name'];
					}
					$timeOrder=$rs['TimeOrder'];
                    
           		 ?>
                    	<tr style="height:25px;">
                        <td style="border:1px solid #999;line-height:30px"><img src="../images/<?=$imageCar;?>" style="width:50px;"/></td>
                        <td width="300px" style="border:1px solid #999; padding:10px"> 
                        <span style="line-height:25px"><b><?=$perName;?></b> </span>
                        </td>
                        <td width="200px" style="border:1px solid #999; padding:10px"> 
                        <span style="line-height:25px"><b><?=$timeOrder;?></b> </span>
                        </td>
                        <td style="border:1px solid #999;line-height:30px">
                        <a href="orderdetail.php?id=<?=$idOrder?>">
                        <img src="../images/view.png" />
                        </a>     
                         </td>
                       </tr>
                    <?php 
						}
					?>
                    </table>
                    
                    
                    <?php
            if(isset($_REQUEST["id"])){
                $newsid=$_REQUEST["id"];
                $check = mysql_query("select * from cars where CarID=$newsid");
                $result_check = mysql_fetch_array($check);
                if($result_check[0] > 0 ){
                    
                    $query = mysql_query("delete from cars where CarID=$newsid");
                    if($query>0){
                        echo("<script>alert('Delete success.');window.location='listcar.php'</script>");
                    }else{
                        echo("<script>window.location='loi.php?loi=xoacl'</script>");
                    }
				}else{
                	echo("<script>alert('News not found !.');</script>");
	            }
            }
        ?>
                </div>
                <!-- InstanceEndEditable -->
                <!-- // #main -->
                
              <div class="clear"></div>
            </div>
            <!-- // #container -->
        </div>	
        <!-- // #containerHolder -->
        
        <p id="footer">EPROJECT SEM I - APTECH</p>
    </div>
</body>
<!-- InstanceEnd -->